/*
 * Copyright 2006-2008 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package net.martinimix.service.payment.handler;

import java.util.Collection;

import org.springframework.core.Ordered;

import net.martinimix.domain.payment.BillMeLaterAccount;
import net.martinimix.domain.payment.Payment;
import net.martinimix.domain.payment.PaymentMethod;
import net.martinimix.service.payment.BillMeLaterPaymentService;

/**
 * Provides a Bill Me Later payment handler adapter allowing a
 * Bill Me Later payment service to perform as a payment handler.
 * 
 * @author Scott Rossillo
 *
 */
public class BillMeLaterPaymentHandlerAdapter 
		extends BillMeLaterPaymentService
		implements PaymentHandler, Ordered {
	
	private int order;
	
	/**
	 * Creates a new Bill Me Later payment handler adapter.
	 */
	public BillMeLaterPaymentHandlerAdapter() { }

	/* (non-Javadoc)
	 * @see net.martinimix.service.payment.handler.PaymentHandler#authorizationRequired(net.martinimix.domain.payment.PaymentMethod)
	 */
	public boolean authorizationRequired(PaymentMethod paymentMethod) {
		return true;
	}
	
	/* (non-Javadoc)
	 * @see net.martinimix.service.payment.handler.PaymentHandler#findPayment(net.martinimix.domain.payment.PaymentMethod, java.util.Collection)
	 */
	public Payment findPayment(PaymentMethod paymentMethod,
			Collection paymentMethods) {
		
		return null;
	}

	/* (non-Javadoc)
	 * @see org.springframework.core.Ordered#getOrder()
	 */
	public int getOrder() {
		return order;
	}

	/**
	 * Sets the order for this payment handler.
	 * 
	 * @param order the order for this payment handler
	 * 
	 * @see #getOrder()
	 */
	public void setOrder(int order) {
		this.order = order;
	}
	
	/* (non-Javadoc)
	 * @see net.martinimix.service.payment.handler.PaymentHandler#supports(net.martinimix.domain.payment.PaymentMethod)
	 */
	public boolean supports(PaymentMethod paymentMethod) {
		return BillMeLaterAccount.class.isAssignableFrom(paymentMethod.getClass());
	}

}
